
var app = new Vue({
	el: "#app",
	data: {
		defaultActive: 0,
		movieId: "", //影片id
		introduceList: '', //介绍集合
		defaultVideoUrl: "", //默认播放链接
		defaultVideoImg: "" ,//默认封面图
		operate:'',//是否可以购票
		header:false,//导航栏是否显示
		shareName:"",
		shareTitle:"",
		shareImg:""
	},

	mounted: function() {
		function GetQueryString(name){//用JS获取地址栏参数的方法
			var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if(r!=null)return  unescape(r[2]); return '';
		};
		if(GetQueryString("movieId")) {
			this.movieId = GetQueryString("movieId");
		}else{
			this.movieId = sessionStorage.getItem("movieIdDy");
		}
		if(GetQueryString("operate")){
			this.operate = GetQueryString("operate");
			this.header = false;
		}else{
			this.operate = sessionStorage.getItem("operate");
		}
		console.log(this.operate)
		console.log(this.movieId);
		this.movieInfo();
		//					this.introduceList = JSON.parse(sessionStorage.getItem('introduceList'));
		//					this.defaultVideoUrl = this.introduceList.videos[0].url;
		//					this.defaultVideoImg = this.introduceList.videos[0].img;
		//					console.log(this.introduceList)
	},
	filters: {
		tm: function(s) {
			var h;
			h = Math.floor(s / 60);
			s = s % 60;
			h += '';
			s += '';
			h = (h.length == 1) ? '0' + h : h;
			s = (s.length == 1) ? '0' + s : s;
			return h + ':' + s;
		}
	},
	methods: {
		onload:function(){
			window.location.href = "https://lkme.cc/Z4D/AjysU6XdJ";
		},
		movieInfo: function() { //影片详细信息
			var timestamp = new Date().format('yyyy-MM-dd hh');
			var paramObj = {
				movieId: this.movieId
			};
			var param = JSON.stringify(paramObj);
			var sign = hex_sha512(param + timestamp);
			this.$http.post(baseUrl + '/new_movie/movie/movieInfo', {
				param: param,
				sign: sign
			}, {
				emulateJSON: true
			}).then(function(data) {
				// alert(data);
				this.introduceList = data.data.Result;
				this.defaultVideoUrl = data.data.Result.videos[0].url;
				this.defaultVideoImg = data.data.Result.videos[0].img;
				console.log(this.introduceList);
				this.shareName = this.introduceList.name+"火热上映中，邀您一起观看",
		        this.shareTitle = this.introduceList.name;
		        this.shareImg = this.introduceList.avatar.replace('w.h', "60.60")
		        this.getShare();
			}, function(s) {
				console.log(s)
			});

		},
		defaultItem: function(item, index) {
			console.log(index)
			this.defaultVideoUrl = item.url;
			this.defaultVideoImg = item.img;
			this.defaultActive = index;
		},
		getShare:function(){
			share(this.shareTitle, this.shareName, this.shareImg, window.location.href.split("#")[0])
		}
	}
})